test(config): assert aiohttp User-Agent test actually verifies the request#1933
Open
anxkhn wants to merge 1 commit into
Open
test(config): assert aiohttp User-Agent test actually verifies the request#1933anxkhn wants to merge 1 commit into
anxkhn wants to merge 1 commit into
Conversation
…quest test_agent_is_used_aiohttp exercised the aiohttp User-Agent override (set_http_lib_agents) but discarded the response and had no assertion, so it verified nothing. A regression in the aiohttp branch of set_http_lib_agents would still pass this test. Its requests and httpx siblings both assert status_code == 200. Return the response status from the coroutine and assert it equals 200, mirroring the siblings, so a broken aiohttp User-Agent makes the request unserved and fails the test. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
jmartin-tech
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_agent_is_used_aiohttpintests/test_config.pyexercised the aiohttpUser-Agent override (
_config.set_http_lib_agents({"aiohttp": ...})) but threwthe response away (
html = await response.text()) and had no assertion, so itverified nothing. A regression in the aiohttp branch of
set_http_lib_agentswould still pass this test, i.e. it is a false-coverage / mutation-survivor test.
Its two siblings both assert the request was actually served with the expected
header:
test_agent_is_used_requests:assert requests.get(...).status_code == 200test_agent_is_used_httpx:assert httpx.get(...).status_code == 200This makes the aiohttp coroutine return
response.statusand asserts it equals200, mirroring the siblings.pytest_httpserveronly serves the request whenthe incoming
User-Agentmatches the expected header, so if the aiohttpUser-Agent override breaks, the request goes unserved (500) and the test now
fails instead of passing silently. A terse assert message documents the expected
behaviour, as the repo's contribution guide asks.
Test-only, one file,
+4/-2. No production code changes.Verification
python -m pytest tests/python -m pytest tests/test_config.py::test_agent_is_used_aiohttp-> 1 passedpython -m pytest tests/test_config.py-> 71 passed (no regressions)temporarily disabling the aiohttp branch of
set_http_lib_agentsmakespytest_httpserverreturn 500 for the unexpectedUser-Agent, and the newassertion fails (
assert 500 == 200) with the descriptive message. It passesagain once the override is restored. This confirms the test is now a real
red/green regression guard rather than a vacuous pass.
black --check tests/test_config.py.Not a duplicate
No open PR touches
test_agent_is_used_aiohttporset_http_lib_agentsin arelated way. The open PRs that edit
tests/test_config.pydo so at unrelatedfunctions: #1857 (deprecated
-m/--model_*CLI-flag removal), #1816 (aparallel-attempts test), #1790 (structured exit codes; its
set_http_lib_agentscalls save/restore prior agents inside the worker-count test, not this one), and
#1651 (exit-code tests). A keyword scan of open PRs for
aiohttp/user-agent/
set_http_lib_agents/agent is usedreturns nothing relevant, and no openissue tracks this test. (The related leakreplay test-coverage fix is a separate
PR, #1914, which touches only
tests/probes/test_probes_leakreplay.py.)AI assistance
AI assistance was used to prepare this change. I have reviewed every changed
line, reproduced the missing-coverage behaviour and the fix locally (confirming
red -> green), and ran the test suite for the affected file.
Notes for maintainers scope
test(config):conventional-commit style already used in the repo(e.g. test(config): regression guard for config_files dedup #1791).
Co-authored-by: Claudetrailer are in the commit.under another license).